/**
 * 判断文件是否存在
 */
import common from '../../tnxet-common.js';
import util from '../main-util.js';
import fs from 'fs';

export default {
    name: common.event.file.exists,
    listen(filePath) {
        return new Promise((resolve, reject) => {
            if (filePath) {
                filePath = util.file.getAbsolutePathBasedOnApp(filePath);
                const exists = fs.existsSync(filePath);
                resolve(exists);
            } else {
                reject('Invalid filePath: ' + filePath);
            }
        });
    },
}
